package  main

import "fmt"

func main() {
	//1.数组
	//// 内存中已开辟了空间 内存初始化的值位0
	//var numbers [3]int
	//numbers[0] = 333
	//numbers[1] = 666
	//numbers[2] = 999
	//fmt.Println(numbers)
	//
	//// 方式二：先声明 后赋值
	//var names = [2]string{"胡皓","ALEX"}
	//fmt.Println(names) //[胡皓 ALEX]
	//
	//// 方式三： 声明+赋值+指定位置
	//var ages = [3]int{0:87,1:73,2:34}
	//fmt.Println(ages) //[87 73 34]
	//
	//// 方式四：省略个数
	//var ids = [...]string{"1","2","3"}	//[1 2 3]
	//fmt.Println(ids)
	//var genders = [...]string{0:"nan",2:"other"}//[nan  other]
	//fmt.Println(genders)
	////var genders = [...]string{0:"nan",1:"nv",2:"other"}//[nan  other]
	////fmt.Println(genders)// [nan nv other]

	//// 指针数组
	//// 声明 指针类型的数组（指针类型） 不会开辟内存初始化数组中的值 numbers = nil
	//var numbers *[3]int
	//fmt.Println(numbers)//<nil>
	//// 声明数组并初始化 返回的是指针类型的数组
	//genders := new([3]int)
	//fmt.Println(genders)// &[0 0 0]

	////2.数组属性
	////数组长度
	//names1 := [3]string{"alex", "huhao", "lufei"}
	//fmt.Println(len(names1))
	//
	////数组索引
	//names2 := [3]string{"alex", "huhao", "lufei"}
	//fmt.Println(names2[0]) //alex
	//fmt.Println(names2[1]) //huhao
	//fmt.Println(names2[2]) //lufei
	//
	////数组切片
	//names3 := [3]string{"alex", "huhao", "lufei"}
	//data := names3[0:1] //包头不包尾
	//fmt.Println(data)   // [alex]
	//
	////循环
	//names4 := [3]string{"alex", "huhao", "lufei"}
	//for i := 0; i < len(names4); i++ {
	//	fmt.Println(names4[i]) //alex huhao lufei
	//}
	//
	//for key, item := range names4 {
	//	fmt.Println(key, item) //0 alex	1 huhao	2 lufei
	//}
	//for key, _ := range names4 {
	//	fmt.Println(key) //0 1 2
	//}
	//for _, item := range names4 {
	//	fmt.Println(item) //ale huhao lufei
	//}	//3.嵌套数组
	//	//3.1声明后赋值
		var data [2][3]int
		data[0] = [3]int{11,22,33}
		data[1] = [3]int{44,55,66}
		fmt.Println(data) //[[11 22 33] [44 55 66]]
		data[0][0] = 12
		fmt.Println(data) //[[12 22 33] [44 55 66]]
		//3.2 声明+赋值
		data2 := [2][3]int{[3]int{11,22,33},[3]int{44,55,66}} //[[11 22 33] [44 55 66]]
		fmt.Println(data2)

}